import { toFail, toSuccess, useEntityManager } from "@sker/core"
import { KsAccount } from "@sker/entities"
import { useData } from "@sker/runtime"
import { z } from "zod"


export default async () => {
    const input = z.object({
        name: z.string()
    })
    const body = input.parse(useData())
    const account = await useEntityManager(async (m) => {
        return await m.findOne(KsAccount, { where: { name: body.name } })
    })
    if (account) {
        return toSuccess(account)
    }
    return toFail(`不存在`)
}
